package com.sky.orangehireserver.common.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 简历表
 * @TableName resumes
 */
@TableName(value ="resumes")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Resumes implements Serializable {
    /**
     * 简历ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 候选人ID
     */
    @TableField(value = "candidate_id")
    private Long candidateId;

    /**
     * MinIO文件对象ID
     */
    @TableField(value = "file_id")
    private String fileId;

    /**
     * 解析后的简历JSON
     */
    @TableField(value = "parsed_json")
    private Object parsedJson;

    /**
     * 上传时间
     */
    @TableField(value = "uploaded_at")
    private LocalDateTime uploadedAt;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Resumes other = (Resumes) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getCandidateId() == null ? other.getCandidateId() == null : this.getCandidateId().equals(other.getCandidateId()))
            && (this.getFileId() == null ? other.getFileId() == null : this.getFileId().equals(other.getFileId()))
            && (this.getParsedJson() == null ? other.getParsedJson() == null : this.getParsedJson().equals(other.getParsedJson()))
            && (this.getUploadedAt() == null ? other.getUploadedAt() == null : this.getUploadedAt().equals(other.getUploadedAt()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getCandidateId() == null) ? 0 : getCandidateId().hashCode());
        result = prime * result + ((getFileId() == null) ? 0 : getFileId().hashCode());
        result = prime * result + ((getParsedJson() == null) ? 0 : getParsedJson().hashCode());
        result = prime * result + ((getUploadedAt() == null) ? 0 : getUploadedAt().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", candidateId=").append(candidateId);
        sb.append(", fileId=").append(fileId);
        sb.append(", parsedJson=").append(parsedJson);
        sb.append(", uploadedAt=").append(uploadedAt);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}